package com.framework.manager;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;

import java.util.Locale;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2021/11/14 15:02
 */
@Component
public class MessageManager {

    @Autowired
    private MessageSource messageSource;

    public String getChinaMessage(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        Locale locale = Locale.CHINA;
        return messageSource.getMessage(code, null, locale);
    }
}
